import request from '@/utils/request'
import type {
  TrademarkResponsePageData,
  Trademark,
  BaseResponseData,
  TrademarkResponseData,
} from './type'
//品牌管理接口地址
enum API {
  //获取品牌列表信息
  Trademark_GetPageList = '/admin/product/baseTrademark',
  //修改品牌信息
  Update_Trademark = '/admin/product/baseTrademark/update',
  //添加品牌信息
  Save_Trademark = '/admin/product/baseTrademark/save',
  //删除品牌信息
  Delete_Trademark = '/admin/product/baseTrademark/remove/',
  //获取全部品牌数据
  GetAllTrademarkList_URL = '/admin/product/baseTrademark/getTrademarkList',
}

//获取品牌信息分页列表
export const TrademarkGetPageList = (pageIndex: number, pageSize: number) =>
  request.get<any, TrademarkResponsePageData>(
    API.Trademark_GetPageList + `/${pageIndex}/${pageSize}`,
  )

//添加或者修改品牌信息
export const AddOrUpdateTrademark = (data: Trademark) => {
  //如果没有ID表示添加，否则表示修改
  if (data.id) {
    return request.put<any, BaseResponseData>(API.Update_Trademark, data)
  } else {
    return request.post<any, BaseResponseData>(API.Save_Trademark, data)
  }
}
//删除品牌信息
export const DeleteTrademark = (id: number) =>
  request.delete<any, any>(API.Delete_Trademark + id)
//获取全部品牌信息列表
export const GetAllTrademark = () =>
  request.get<any, TrademarkResponseData>(API.GetAllTrademarkList_URL)
